'''
This file is part of ModeliMark.

ModeliMark is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.

ModeliMark is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with ModeliMark.
If not, see <http://www.gnu.org/licenses/>.

Copyright 2011 Jens Frenkel
'''

import loadResultFile
import matplotlib.pyplot as plt

class Chart(object):
    '''
    classdocs
    '''


    def __init__(self, file, title, picture, lines=[1,1,1,1]):
        '''
        Constructor
        '''
        assert(isinstance(file,str))
        assert(isinstance(title,str))
        assert(isinstance(picture,str))
        
        self.file = file
        self.title = title
        self.picture = picture
        
        data = loadResultFile.LoadResultFile(self.file)
        
        legend = list();
        if (lines[0] == 1):
            plt.plot(data.simulate[0], data.simulate[1])
            legend.append('simulate')
        if (lines[1] == 1):
            plt.plot(data.translate[0], data.translate[1])
            legend.append('translate')
        if (lines[2] == 1):
            plt.plot(data.flatten[0], data.flatten[1])
            legend.append('flatten')
        if (lines[3] == 1):
            plt.plot(data.open[0], data.open[1])
            legend.append('open')
        plt.legend( legend, loc='upper left')
        plt.ylabel('time[s]')
        plt.xlabel('number of equations')
        plt.title(title)
        plt.legend()
        plt.savefig(picture)
        

        
        
        